<template>
    <div class="numbox-container">
        <!--  -->
        <div class="mui-numbox" data-numbox-min='1'  style="height: 25px;">
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input id="test" class="mui-input-numbox" type="number" :value="initcount" @change='countChanged' ref="numbox" style="font-size: 12px;" readonly="" />
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
        </div>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'

    export default{
        mounted(){
            mui('.mui-numbox').numbox()//初始化数字选择框组件
        },
        methods:{
            countChanged(){//当文本框数据被修改时，立即把最新的值同步到store中的cart中去
                this.$store.commit('updateGoodsCount',
                    {
                        id:this.goodsid,
                        count:this.$refs.numbox.value
                    }
                )
            }
        },
        props:['initcount','goodsid'],

    }
</script>

<style scoped="">
.numbox-container{
    display: inline-block;
}
</style>